import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../models/payments_model.dart';

class PaymentsAddressWidget extends ConsumerStatefulWidget {
  final List<PaymentsUserAddressesModel> userAddresses;

  const PaymentsAddressWidget({super.key, required this.userAddresses});

  @override
  _PaymentsAddressWidgetState createState() => _PaymentsAddressWidgetState();
}

class _PaymentsAddressWidgetState extends ConsumerState<PaymentsAddressWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      margin: const EdgeInsets.only(bottom: 10),
      padding: const EdgeInsets.all(10),
      decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Colors.white),
      child: Row(
        children: [
          const Icon(
            Icons.add_location_alt_rounded,
            color: Colors.teal,
            size: 24,
          ),
          const SizedBox(width: 10),
          Expanded(
            flex: 1,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text.rich(
                  TextSpan(
                    text: widget.userAddresses[0].receiver,
                    style: const TextStyle(fontSize: 20),
                    children: [
                      const WidgetSpan(
                        child: SizedBox(
                          width: 15,
                        ),
                      ),
                      TextSpan(
                        text: widget.userAddresses[0].contact,
                        style: const TextStyle(fontSize: 16),
                      )
                    ],
                  ),
                ),
                const SizedBox(height: 8),
                Text.rich(
                  TextSpan(
                    text: widget.userAddresses[0].fullLocation,
                  ),
                ),
              ],
            ),
          ),
          const SizedBox(width: 10),
          const Icon(
            Icons.arrow_forward_ios_sharp,
            color: Colors.grey,
            size: 18,
          ),
        ],
      ),
    );
  }
}
